<script>
import axios from 'axios'
export default {
  name: "HttpRequest",
  data(){
    return{
      users:[]
    }
  },
  methods:{
    getData(){
      axios.get('https://jsonplaceholder.typicode.com/users',{
        headers:{
          'Authorization': localStorage.getItem('token')
        },
       params:{
         roleId: 3,
         startTime: '2021-12-12',
         endTime:'2024-12-12',
         keyword:'abc'
       }

      })
          .then(resp=>{
        console.log('ok:',resp)
            this.users = resp.data;
      }).catch(error=>{
        console.log(error)
      })
    }
  }
}
</script>

<template>
    <button @click="getData">获取数据</button>
    <ul>
      <li v-for="(user,index) in users" :key="index">--{{user.id}}--{{user.name}}--{{user.username}}--{{user.email}}</li>
    </ul>
</template>

<style scoped>

</style>